/**
 * 测试坐骑属性计算脚本
 * 验证的卢的属性计算是否正确
 */

// 的卢属性配置（根据表格数据）
const diluConfig = {
  name: "的卢",
  attributes: {
    hp: {
      initial: 17100,
      maxLevels: {
        notPromoted: 17100,
        firstPromotion: 25180,
        secondPromotion: 35380,
        thirdPromotion: 47940,
      },
    },
  },
};

// 属性计算公式
function calculateMountAttribute (initialValue, maxValue, maxLevel, currentLevel) {
  const levelRatio = Math.floor(currentLevel) / maxLevel;
  return Math.floor(initialValue + (maxValue - initialValue) * levelRatio);
}

function testDiluCalculation () {
  console.log('🐎 测试的卢属性计算');
  console.log('='.repeat(50));

  const config = diluConfig;
  const level = 43;
  const transLevel = 0; // 未转

  // 根据转职等级确定最大等级和属性上限
  let maxLevel, maxHp;

  switch (transLevel) {
    case 0: // 未转
      maxLevel = 100;
      maxHp = config.attributes.hp.maxLevels.notPromoted;
      break;
    case 1: // 一转
      maxLevel = 120;
      maxHp = config.attributes.hp.maxLevels.firstPromotion;
      break;
    case 2: // 二转
      maxLevel = 140;
      maxHp = config.attributes.hp.maxLevels.secondPromotion;
      break;
    case 3: // 三转
      maxLevel = 160;
      maxHp = config.attributes.hp.maxLevels.thirdPromotion;
      break;
    default:
      maxLevel = 100;
      maxHp = config.attributes.hp.maxLevels.notPromoted;
  }

  // 计算期望属性
  const expectedHp = calculateMountAttribute(
    config.attributes.hp.initial,
    maxHp,
    maxLevel,
    level
  );

  console.log(`转职等级: ${transLevel} (最大等级: ${maxLevel})`);
  console.log(`等级: ${level}`);
  console.log(`初始气血: ${config.attributes.hp.initial}`);
  console.log(`最大气血: ${maxHp}`);
  console.log(`期望气血: ${expectedHp}`);

  // 测试不同等级
  console.log('\n📊 测试不同等级的属性计算:');
  console.log('等级\t期望气血');
  console.log('----\t--------');

  for (let testLevel = 1; testLevel <= 100; testLevel += 10) {
    const testHp = calculateMountAttribute(
      config.attributes.hp.initial,
      maxHp,
      maxLevel,
      testLevel
    );
    console.log(`${testLevel}\t${testHp}`);
  }

  // 验证满级属性
  console.log('\n✅ 验证满级属性:');
  const maxLevelHp = calculateMountAttribute(
    config.attributes.hp.initial,
    config.attributes.hp.maxLevels.thirdPromotion,
    160,
    160
  );

  console.log(`三转160级气血: ${maxLevelHp} (期望: 47940)`);
  console.log(`气血匹配: ${maxLevelHp === 47940 ? '✅' : '❌'}`);
}

// 运行测试
testDiluCalculation();